package org.jdsm.gae.komarichyn.profile;

import org.apache.struts2.util.StrutsTypeConverter;
import org.jdsm.flow.core.users.IGroup;

import javax.annotation.Resource;
import java.util.Map;

/**
 * User: mikom
 * Date: 3/6/13
 * Time: 6:42 PM
 */
public class GroupConverter extends StrutsTypeConverter {

    @Resource
    private IGroup group;

    @Override
    public Object convertFromString(Map context, String[] values, Class toClass) {
        if (group == null)
            return null;

        group.setId(new Long(values[0]));
        return group;
    }

    @Override
    public String convertToString(Map context, Object o) {
        return String.valueOf(((IGroup)o).getId());
    }
}
